﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;

namespace Twi.COMMON.Core
{
    /**
     * Author:feitianxinhong
     * Create Date:2015-04-28
     * Description:XNode扩展方法
     */
    public static class ExtensionXmlNode
    {
        /// <summary>
        /// 将XmlNode对象转化为XElement对象
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static XElement ToXElement(this XmlNode node)
        {
            XDocument xDoc = new XDocument();
            using (XmlWriter xmlWriter = xDoc.CreateWriter())
            {
                node.WriteTo(xmlWriter);
            }
            return xDoc.Root;
        }

    }
}
